files = ['HH';'HV';'VH';'VV'];
pol = ['RL';'RR';'LL';'LR'];
Ts = [11,20,30,40,50,55,60,65,70,80,100,130,160,190,220,250,275,296];
offsets=[]
%Ts = [80]%,100,130,160,190,220,250,275,296];
figure
hold on
Esall=zeros(18,991);
dataall=zeros(18,991);
for num=1:length(Ts)
    filename=['HH',num2str(Ts(num)),'.txt'];
    if Ts(num)==80
        filename=['HH',num2str(Ts(num)),'_2.txt'];
        data=readmatrix(filename);
        plot(data(26:end,1),data(26:end,2)+50*(num-1),'.-','Color',[(num)/20 0 0]);
        Es=data(26:end,1);
        Is=data(26:end,2);
        dataall(num,:)=data(26:(26+990),2);
        Esall(num,:)=data(26:(26+990),1);
    else
        data=readmatrix(filename);
        plot(data(260:end,1),data(260:end,2)+50*(num-1),'.-','Color',[(num)/20 0 0]);
        Es=data(260:1250,1);
        Is=data(260:1250,2);
        dataall(num,:)=data(260:(260+990),2);
        Esall(num,:)=data(260:(260+990),1);
        ylim([20,1000])
        title('VH')
        
    end
end
figure
imagesc(Es,Ts,dataall)
colormap('jet')
clim([10,50])
%% offset





figure
hold on
dataall=zeros(19,1024);
for num=1:length(Ts)
    filename=['HV',num2str(Ts(num)),'.txt'];
    data=readmatrix(filename);
    plot(data(:,1)/8.06554,data(:,2)+50*(num-1),'.-','Color',[(num)/20 0 0]);
    Es=data(:,1)/8.06554;
    dataall(num,:)=data(501:1524,2);
    ylim([20,1000])
    title('HV')
end
figure
imagesc(Es,Ts,dataall)
colormap('jet')
clim([10,60])
%% Imagesc plot
Tplot=0:305;
dataplot=zeros(length(Tplot),127);
Tline=[];
for num=1:(length(Ts)-1)
    Tline(num)=(Ts(num)/2+Ts(num+1)/2)-0.1;
end
for idx=1:length(Tplot)
    numT=sum(Tplot(idx)>Tline)+1
    dataplot(idx,:)=dataall(numT,:);
end
figure(52);
imagesc(Es,Tplot,dataplot)
colormap("jet")
clim([0,80])
xlim([500,530])
ylim([0,300])
figure


[X,Y]=meshgrid(Es,Ts)
mesh(X,Y,dataall)
colormap('jet')
clim([15,60])
xlim([55,70])